package mylab.utils.common;

import java.io.File;
import java.nio.charset.StandardCharsets;

import lombok.experimental.UtilityClass;

@UtilityClass
public class FileUtil extends cn.hutool.core.io.FileUtil {

    public long getFileSize(File file) {
        return (file.exists() && file.isFile() ? file.length() : -1);
    }

    public void writeFile(String content, String path, boolean isAppend) {
        if (isAppend) {
            FileUtil.appendString(content, path, StandardCharsets.UTF_8);
        } else {
            FileUtil.writeString(content, path, StandardCharsets.UTF_8);
        }
    }
}
